package buffer.CNN;

import java.io.*;
import java.net.FileNameMap;
import java.net.URLConnection;

public class Recursion {

    public static void main(String[] src) throws IOException {
        String path = "C:\\Users\\Dzq\\Desktop\\微信图片_20180615131650.jpg";
        String filePath="D:\\FTP\\xx.txt";
        String s=getType(filePath);
        InputStream inp = readInput(path);
        OutputStream out=new FileOutputStream(filePath);

        byte[] bytes = new byte[1024];
        int i=0;
        while ((i=inp.read(bytes)) !=-1) {
            out.write(bytes);
        }


    }

    public static InputStream readInput(String path) throws FileNotFoundException {
        File file = new File(path);
        InputStream inp = new FileInputStream(file);
        return inp;

    }

    public static String getType(String filePath){
        FileNameMap fileNameMap = URLConnection.getFileNameMap();
        String type = fileNameMap.getContentTypeFor(filePath);
        return type;
    }

}
